package com.yyf.test1.Interface.Impl;

import com.yyf.test1.Interface.LikeRcorder;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class test implements LikeRcorder {
   private Set<String> likeSet=new HashSet<>();
    @Override
    public void like(String userName) {
        if(likeSet.contains(userName)){
            likeSet.remove(userName);
        }else{
            likeSet.add(userName);
        }
    }

    @Override
    public String[] getLikeUsers() {
        return likeSet.toArray(new String[0]);
    }
    public static void main(String[] args){
        LikeRcorder recorder=new test();
        String[] users={"张三","李四","王五"};
        for(String user:users){
            recorder.like(user);
        }
        System.out.println(Arrays.toString(recorder.getLikeUsers()));
    }
}
